#include "mainwindow.h"


MainWindow::MainWindow(MyCallback *myCallback_, QWidget *parent) :
    QMainWindow(parent)
{




    glwidget = new GLWidget(myCallback_, this);
    finishScreen = new FinishScreen(this);
    firstScreen = new FirstScreen(this);



    //this->resize(720,1134);
    //this->resize(720,1000);
    this->resize(800,1280);

    glwidget->resize(this->size());
    firstScreen->resize(this->size());
    finishScreen->resize(this->size());




    //glwidget->show();
    glwidget->hide();
    finishScreen->hide();
    //firstScreen->hide();

    connect(firstScreen,SIGNAL(startGame()),this,SLOT(startGame()));
    connect(glwidget,SIGNAL(finishGame()),this,SLOT(finishGame()));

    close();
}


void MainWindow::startGame()
{
    firstScreen->hide();
    finishScreen->hide();
    emit startEegRecording(firstScreen->getUser(),firstScreen->getDesc());
    glwidget->setDifficultyLevel(firstScreen->getCurrentDifficultyLevel());
    glwidget->setUser(firstScreen->getUser(),firstScreen->getDesc());
    glwidget->show();

}

void MainWindow::finishGame()
{
    finishScreen->setError(glwidget->getError());
    glwidget->hide();
    finishScreen->show();
    this->update();

}

void MainWindow::cqValue(QString channel, double value)
{
    firstScreen->cqValue(channel,value);
}

void MainWindow::kill()
{
    system("su -c 'killall -9 org.kde.necessitas.example.MotorTask'");
}
